package com.dubbo;

import com.alibaba.dubbo.common.json.JSON;
import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ReferenceConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.alibaba.dubbo.config.utils.ReferenceConfigCache;
import com.alibaba.dubbo.rpc.service.GenericService;

import java.util.HashMap;
import java.util.Map;

public class GenericTest {

    public static void main(String[] args) {
        ReferenceConfig<GenericService> referenceConfig = new ReferenceConfig<>();
        referenceConfig.setApplication(new ApplicationConfig("kwg-dsp-asset"));
        referenceConfig.setRegistry(new RegistryConfig("zookeeper://127.0.0.1:2189"));
        referenceConfig.setVersion("1.0.1");
//        referenceConfig.setGroup("dubbo");
        referenceConfig.setInterface("com.kwggroupholdings.dsp.asset.api.PointQueryService");
        referenceConfig.setTimeout(5000);
        //泛化引用，类型为true
        referenceConfig.setGeneric(true);
//        GenericService genericService = referenceConfig.get();
        ReferenceConfigCache cache = ReferenceConfigCache.getCache();
        GenericService genericService = cache.get(referenceConfig);
        //POJO参数转换为MAP
        Map<String, Object> map = new HashMap<>();
        map.put("class","com.kwggroupholdings.dsp.asset.api.FindPointById");
        map.put("id","0000642b9795493fb676f496d16ca954");
        Object result = genericService.$invoke("findById",new String[]{"com.kwggroupholdings.dsp.asset.api.FindPointById"},new Object[]{map});
        System.out.println(result);


    }


}
